package main

//暴力 73/77 超时
func handleQuery(nums1 []int, nums2 []int, queries [][]int) []int64 {
	n := len(nums1)
	res := make([]int64, 0)
	for _, query := range queries {
		switch query[0] {
		case 1:
			l, r := query[1], query[2]
			for i := l; i <= r; i++ {
				if nums1[i] == 1 {
					nums1[i] = 0
				} else if nums1[i] == 0 {
					nums1[i] = 1
				}
			}
		case 2:
			p := query[1]
			for i := 0; i < n; i++ {
				nums2[i] = nums1[i]*p + nums2[i]
			}
		case 3:
			var sum int64 = 0
			for i := 0; i < n; i++ {
				sum += int64(nums2[i])
			}
			res = append(res, sum)
		}
	}
	return res
}
